<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class OrderItems extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'product_id' => $this->product_id,
            'amount' => $this->amount,
            'price' => $this->price,
            'detail' => $this->detail,
            'is_review' => (string)$this->reviewed_at ? 1 : 0, // 是否评论
        ];
    }
}
